package com.rest.demo.consumerest;

import com.alibaba.fastjson.JSONObject;
import com.rest.demo.response.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 * @decription
 * @Date 2017-11-16 16:30
 */
@RestController
public class ConsumeRestController {

    @Autowired
    private Restconfigurtion restconfigurtion;

    @Autowired
    private RestTemplateBuilder builder;

    @PostMapping(value = "/consumeString")
    public ResponseEntity consumeString() {
        String result = restconfigurtion.run(restconfigurtion.restTemplate(builder));
        JSONObject jsonObject = JSONObject.parseObject(result);
        return new ResponseEntity().success(jsonObject);
    }
}
